package hospital;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.test.R;

public class quiz_failure extends Activity {
    /** Called when the activity is first created. */
	ArrayList<coupons> coupon_list;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.quiz_failure);
		
		final Button replay_quiz_btn = (Button)findViewById(R.id.replay_quiz_btn);
		final Button end_quiz_btn = (Button)findViewById(R.id.end_quiz_btn);
		ImageView failure_title = (ImageView)findViewById(R.id.failure_title);
		TextView quiz_hint_text = (TextView)findViewById(R.id.quiz_hint_text);
		
		//if(items.event_list.get(items.quiz_no).getQuiz_type() == 3){
		//	failure_title.setImageResource(R.drawable.searchgame_title);
		//}else if(items.event_list.get(items.quiz_no).getQuiz_type() == 1 || items.event_list.get(items.quiz_no).getQuiz_type() == 4){
			failure_title.setImageResource(R.drawable.oxquiz_title);
		//	if(items.event_list.get(items.quiz_no).getQuiz_type() == 4){
				quiz_hint_text.setText("화이팅~");
		//	}
		//}		
		replay_quiz_btn.setOnTouchListener(new OnTouchListener(){
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
					replay_quiz_btn.setBackgroundResource(R.drawable.replay_btn_down);
				}else if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
					replay_quiz_btn.setBackgroundResource(R.drawable.replay_btn);
					
					//if(items.event_list.get(items.quiz_no).getQuiz_type() == 1 || items.event_list.get(items.quiz_no).getQuiz_type() == 4){
						Intent intent = new Intent(quiz_failure.this, hospital_oxquiz.class);
						startActivityForResult(intent, 0);
						finish();
					//}		
				}
				return false;
			}
        	
        });
		
		end_quiz_btn.setOnTouchListener(new OnTouchListener(){
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
					end_quiz_btn.setBackgroundResource(R.drawable.gameover_btn_down);
				}else if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
					end_quiz_btn.setBackgroundResource(R.drawable.gameover_btn);
					
					//items.quiz_no=0;
					//items.event_called = false;
					//items.event_list.removeAll(items.event_list);
					
					Intent intent = new Intent(quiz_failure.this, hospital_main.class);
					startActivityForResult(intent, 0);
					finish();
				}
				return false;
			}
        	
        });
    }
    public boolean onKeyDown( int KeyCode, KeyEvent event ){
		if( event.getAction() == KeyEvent.ACTION_DOWN ){
			if( KeyCode == KeyEvent.KEYCODE_BACK ){
				//items.quiz_no=0;
				//items.event_called = false;
				
				Intent intent = new Intent(quiz_failure.this, hospital_main.class);
				startActivityForResult(intent, 0);
				finish();
				
				return false;
			}
		}
		return super.onKeyDown(KeyCode, event);
	}
}
